package com.pbking.facebook.delegates.users
{
	import com.pbking.facebook.Facebook;
	import com.pbking.facebook.FacebookSessionType;
	import com.pbking.facebook.delegates.FacebookDelegate;
	
	/**
	 * This method will be deprecated after the new profile design launches to all users.
	 * 
	 * Returns whether the user (either the session user or user specified by uid) has added the calling application.
	 * 
	 * For Web applications, you must pass either the ID of the user on whose behalf you're making this call or the session key for that user, but not both. If you don't specify a user with the uid parameter, then that user whose session it is will be the target of the call.
	 * 
	 * However, if your application is a desktop application, you must pass a valid session key for security reasons. Do not pass a uid parameter. 
	 */
	public class IsAppAddedDelegate extends FacebookDelegate
	{
		public var uid:String;
		public var isAdded:Boolean;
		
		public function IsAppAddedDelegate(facebook:Facebook, uid:String=null)
		{
			super(facebook);
						
			if ((FacebookSessionType.WEB == facebook.sessionType) && uid) {
				fbCall.useSession = false;
			}
			
			if (uid) {
				this.uid = uid;
				fbCall.setRequestArgument("uid", uid);
			}
			
			fbCall.post("facebook.users.isAppAdded");
		}
		
		override protected function handleResult(result:Object):void
		{
			isAdded	= Boolean(result);
		}
		
	}
}